home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / mus / midi / XGToolset5_src.lha / XGToolset_src / XGDrum / XGDrum.c < prev    next >
C/C++ Source or Header  |  1999-02-13  |  80KB  |  1,883 lines

  1. /*
  2.     XG-DRUM-Editor V1.3
  3.  
  4.     A Bars and Pipes tool for editing the DB50-XG-board from  YAMAHA.
  5.  
  6.     Use it together with the other XG ... .ptool ' s -
  7.  
  8.     © 1998 Alfred & Matthias Faust
  9.  
  10.     The Tool-code based farly on the code for the "pc3.ptool" from  Richard
  11.     Hagen. That's a very good tool,  many thanks to him.
  12.  
  13.     Richard has written his tool with DICE. We altered the code to  compile
  14.     with  the  free  GNU-C-compiler  of  the  ADE.  Especially the part was
  15.     transcripted,   that  place  the  imagedate  in  chip-RAM,   because  the
  16.     GNU-C-compiler  hasn't as yet a keyword like DICE or other compiler for
  17.     this.
  18.  
  19.     This code is released  into  the  Public  Domain,   and  may  be  freely
  20.     distributed in its original form.
  21.  
  22.     It is supplied ``as is'',  and comes with no warranty. This instrument code
  23.     was  released  because it might be useful as a starting point for other
  24.     instrumentmers. However,  if any damage arises from its use,   the  original
  25.     author and we will not be held liable.
  26.  
  27.     You are free to use and modify  this  code  to  your  heart's  content,
  28.     provided you acknowledge me as the original author in any code that you
  29.     might distribute which is based largely on this code.
  30.  
  31.     I acknowledge that the design of this tool is  influenced  strongly  by
  32.     the  example code supplied with the Rules for Tools package. However,  I
  33.     have made substantial contributions of my own.
  34.  
  35.     Matthias & Alfred Faust
  36.     j.k.dax@t-online.de
  37.  
  38.     History:
  39.         1.0 (4.12.1998)
  40.         Initial Release.
  41.  
  42.         1.1 - 1.2
  43.         overjumping, because all tools shall have the same version number
  44.  
  45.         1.3 (13.02.1999)
  46.         all slidervalues will be stored with the tool in the track
  47.  
  48.     
  49. */
  50.  
  51. #include "bars.h"
  52. #include "myheader.h"  // from R.Hagen
  53. #include <libraries/dos.h>
  54. #include <proto/exec.h>
  55. #include <proto/intuition.h>
  56. #include <proto/graphics.h>
  57. #include <exec/memory.h>
  58. #include <exec/execbase.h>
  59. #include <exec/types.h>
  60. #include <string.h>
  61. #include <intuition/intuition.h>
  62.  
  63. #include "soundmatrix.c"  //all the soundnames
  64.  
  65. char version[]="\0$VER:DrumXG-Edit 1.3 (13.12.1999) © Alfred & Matthias Faust";
  66.  
  67. #define DRXG_NAME "XG-Drum-Edit"
  68.  
  69. #define DRXG_ID          0x44525847
  70. #define DRXG_TYPE        (TOOL_NORMAL | TOOL_NOTPAD)
  71.  
  72. //all the default values of the slider-storage
  73. UBYTE initstorage[1580]={
  74. 0x00,0x00,0x40,0x40,0x66,0x03,0x33,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  75. 0x00,0x00,0x40,0x40,0x79,0x03,0x33,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  76. 0x00,0x00,0x40,0x40,0x3F,0x00,0x33,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  77. 0x00,0x00,0x40,0x40,0x7F,0x00,0x33,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  78. 0x00,0x00,0x40,0x40,0x5D,0x04,0x34,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  79. 0x00,0x00,0x40,0x40,0x74,0x04,0x34,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  80. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x4B,0x00,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G-1
  81. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  82. 0x00,0x00,0x40,0x40,0x5E,0x00,0x40,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  83. 0x00,0x00,0x40,0x40,0x62,0x00,0x40,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  84. 0x00,0x00,0x40,0x40,0x5C,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  85. 0x00,0x00,0x40,0x40,0x77,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //C0
  86. 0x00,0x00,0x40,0x40,0x31,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  87. 0x00,0x00,0x40,0x40,0x2F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  88. 0x00,0x00,0x40,0x40,0x34,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  89. 0x00,0x00,0x40,0x40,0x2D,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  90. 0x00,0x00,0x40,0x40,0x4F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  91. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  92. 0x00,0x00,0x40,0x40,0x4B,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G0
  93. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  94. 0x00,0x00,0x40,0x40,0x74,0x00,0x40,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  95. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  96. 0x00,0x00,0x40,0x40,0x66,0x00,0x40,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  97. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //C1
  98. 0x00,0x00,0x40,0x40,0x5D,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  99. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  100. 0x00,0x00,0x40,0x40,0x6E,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  101. 0x00,0x00,0x40,0x40,0x7B,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  102. 0x00,0x00,0x40,0x40,0x6F,0x00,0x18,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  103. 0x00,0x00,0x40,0x40,0x5B,0x01,0x4D,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  104. 0x00,0x00,0x40,0x40,0x71,0x00,0x27,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G1
  105. 0x00,0x00,0x40,0x40,0x5C,0x01,0x4D,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  106. 0x00,0x00,0x40,0x40,0x63,0x00,0x34,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  107. 0x00,0x00,0x40,0x40,0x60,0x01,0x4D,0x20,0x20,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  108. 0x00,0x00,0x40,0x40,0x57,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  109. 0x00,0x00,0x40,0x40,0x63,0x00,0x53,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //C2
  110. 0x00,0x00,0x40,0x40,0x7F,0x00,0x45,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  111. 0x00,0x00,0x40,0x40,0x74,0x00,0x68,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  112. 0x00,0x00,0x40,0x40,0x69,0x00,0x22,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  113. 0x00,0x00,0x40,0x40,0x78,0x00,0x22,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  114. 0x00,0x00,0x40,0x40,0x6B,0x00,0x2E,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  115. 0x00,0x00,0x40,0x40,0x74,0x00,0x40,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  116. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G2
  117. 0x00,0x00,0x40,0x40,0x76,0x00,0x4D,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  118. 0x00,0x00,0x40,0x40,0x7F,0x00,0x33,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  119. 0x00,0x00,0x40,0x40,0x6A,0x00,0x19,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  120. 0x00,0x00,0x40,0x40,0x6E,0x00,0x2E,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  121. 0x00,0x00,0x40,0x40,0x6E,0x00,0x72,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //C3
  122. 0x00,0x00,0x40,0x40,0x57,0x00,0x72,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  123. 0x00,0x00,0x40,0x40,0x49,0x00,0x27,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  124. 0x00,0x00,0x40,0x40,0x59,0x00,0x19,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  125. 0x00,0x00,0x40,0x40,0x6F,0x00,0x40,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  126. 0x00,0x00,0x40,0x40,0x5B,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  127. 0x00,0x00,0x40,0x40,0x5F,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  128. 0x00,0x00,0x40,0x40,0x6C,0x00,0x22,0x64,0x64,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G3
  129. 0x00,0x00,0x40,0x40,0x6C,0x00,0x22,0x64,0x64,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  130. 0x00,0x00,0x40,0x40,0x5A,0x00,0x1C,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  131. 0x00,0x00,0x40,0x40,0x63,0x00,0x15,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  132. 0x00,0x00,0x40,0x40,0x67,0x00,0x65,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  133. 0x00,0x00,0x40,0x40,0x6E,0x00,0x65,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //C4
  134. 0x00,0x00,0x40,0x40,0x7C,0x00,0x5F,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  135. 0x00,0x00,0x40,0x40,0x6A,0x00,0x72,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  136. 0x00,0x00,0x40,0x40,0x58,0x00,0x40,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  137. 0x00,0x00,0x40,0x40,0x6B,0x00,0x68,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  138. 0x00,0x00,0x40,0x40,0x60,0x00,0x68,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  139. 0x00,0x00,0x40,0x40,0x61,0x00,0x15,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  140. 0x00,0x00,0x40,0x40,0x6B,0x00,0x22,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,  //G4
  141. 0x00,0x00,0x40,0x40,0x7F,0x02,0x19,0x5F,0x5F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  142. 0x00,0x00,0x40,0x40,0x7F,0x02,0x19,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  143. 0x00,0x00,0x40,0x40,0x6A,0x00,0x53,0x3F,0x3F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  144. 0x00,0x00,0x40,0x40,0x7B,0x00,0x69,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  145. 0x00,0x00,0x40,0x40,0x44,0x00,0x40,0x7F,0x7F,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  146. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  147. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  148. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  149. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  150. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  151. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00,
  152. 0x00,0x00,0x40,0x40,0x7F,0x00,0x40,0x28,0x28,0x7F,0x00,0x01,0x01,0x40,0x40,0x40,0x40,0x40,0x01,0x00};
  153.  
  154.  
  155. // the litte Icon in the pipeline
  156.  
  157. UWORD *DRXG=NULL;
  158.  
  159. static UWORD DRXGdata[] =
  160. {
  161.         /* Plane 0 */
  162.                 0x7FFF,0xFE00,
  163.                 0x7FFF,0xFE00,
  164.                 0x7F81,0xFE00,
  165.                 0x7EC3,0xDE00,
  166.                 0x7D01,0xF600,
  167.                 0x7D00,0xDE00,
  168.                 0x7D00,0xDE00,
  169.                 0x7D00,0xDE00,
  170.                 0x7A81,0xDE00,
  171.                 0x7743,0xAE00,
  172.                 0x7FFF,0xFE00,
  173.                 0x7FFF,0xFE00,
  174.         /* Plane 1 */
  175.                 0x0000,0x00200,
  176.                 0x0000,0x00600,
  177.                 0x1F83,0xFE00,
  178.                 0x11C7,0xBE00,
  179.                 0x8ABA,0x00F00,
  180.                 0x9B7D,0xBF00,
  181.                 0x9B7D,0xBF00,
  182.                 0x9B7D,0xBF00,
  183.                 0x15BB,0xBE00,
  184.                 0x0EC7,0x5E00,
  185.                 0x1FFF,0xFE00,
  186.                 0x3FFF,0xFE00,
  187.         /* Plane 2 */
  188.                 0x0000,0x00000,
  189.                 0x0000,0x00000,
  190.                 0x1FFD,0xF800,
  191.                 0x1EFB,0xD800,
  192.                 0x1D7D,0xF000,
  193.                 0x1DFE,0xD800,
  194.                 0x1DFE,0xD800,
  195.                 0x1DFE,0xD800,
  196.                 0x1AFD,0xD800,
  197.                 0x177B,0xA800,
  198.                 0x0000,0x00000,
  199.                 0x0000,0x00000
  200. };
  201.  
  202. static struct Image DRXG_image = {
  203.   0, 0,
  204.   24 ,  12 ,  3 ,
  205.   NULL,
  206.   0x1f, 0x00,
  207.   NULL
  208. };
  209.  
  210. //Definitions of the gadgets
  211.  
  212. #define KIT_GADGET           1
  213. #define INSTRUMENT_GADGET    2
  214. #define PITCHCOURSE_GADGET   3
  215. #define PITCHFINE_GADGET     4
  216. #define LEVEL_GADGET         5
  217. #define ALTERNATE_GADGET     6
  218. #define PAN_GADGET           7
  219. #define REVERB_GADGET        8
  220. #define CHORUS_GADGET        9
  221. #define VARFX_GADGET         10
  222. #define KEYASSIGN_GADGET     11
  223. #define RCVNOTEOFF_GADGET    12
  224. #define RCVNOTEON_GADGET     13
  225. #define FICUTOFFREQ_GADGET   14
  226. #define FICUTOFFRESON_GADGET 15
  227. #define ATTACK_GADGET        16
  228. #define DECAYA_GADGET        17
  229. #define DECAYB_GADGET        18
  230. #define VXON_GADGET          19
  231. #define DRUMSET_GADGET       20
  232.  
  233. #define WRITE_GADGET         21
  234. #define DEFAULT_GADGET       22
  235.  
  236.  
  237. //all the gadgets
  238.  
  239. // KIT gadget.
  240. struct PropInfo DRXGGadget1Info = {
  241.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/11,  -1, };
  242. struct Image DRXGImage1 = {
  243.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  244. struct IntuiText DRXGText1 = {
  245.   2, 0, JAM1, -65,  1, NULL, "    Kit", NULL };
  246. struct Gadget DRXGGadget1 = {
  247.   NULL, 70, 52, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  248.   (APTR)&DRXGImage1, NULL, &DRXGText1, NULL, (APTR)&DRXGGadget1Info, KIT_GADGET, NULL };
  249.  
  250. // INSTRUMENT gadget.
  251. struct PropInfo DRXGGadget2Info = {
  252.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/79,  -1, };
  253. struct Image DRXGImage2 = {
  254.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  255. struct IntuiText DRXGText2 = {
  256.   2, 0, JAM1, -65, 1, NULL, "Instrm#", NULL };
  257. struct Gadget DRXGGadget2 = {
  258.   &DRXGGadget1, 70, 42, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  259.   (APTR)&DRXGImage2, NULL, &DRXGText2, NULL, (APTR)&DRXGGadget2Info, INSTRUMENT_GADGET, NULL };
  260.  
  261. // PITCHCOURSE gadget.
  262. struct PropInfo DRXGGadget3SInfo = {
  263.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY *1/128, -1, };
  264. struct Image DRXGImage3 = {
  265.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  266. struct IntuiText DRXGText3 = {
  267.   2, 0, JAM1, -65, 1, NULL, "PitchCs", NULL };
  268. struct Gadget DRXGGadget3 = {
  269.   &DRXGGadget2, 70, 72, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  270.   (APTR)&DRXGImage3, NULL, &DRXGText3, NULL, (APTR)&DRXGGadget3SInfo, PITCHCOURSE_GADGET, NULL };
  271.  
  272. // PITCHFINE gadget.
  273. struct PropInfo DRXGGadget4SInfo = {
  274.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY *1/128, -1, };
  275. struct Image DRXGImage4 = {
  276.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  277. struct IntuiText DRXGText4 = {
  278.   2, 0, JAM1, -65, 1, NULL, "PitchFn", NULL };
  279. struct Gadget DRXGGadget4 = {
  280.   &DRXGGadget3, 70, 82, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  281.   (APTR)&DRXGImage4, NULL, &DRXGText4, NULL, (APTR)&DRXGGadget4SInfo, PITCHFINE_GADGET, NULL };
  282.  
  283. // LEVEL gadget.
  284. struct PropInfo DRXGGadget5SInfo = {
  285.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY *1/128, -1, };
  286. struct Image DRXGImage5 = {
  287.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  288. struct IntuiText DRXGText5 = {
  289.   2, 0, JAM1, -65, 1, NULL, " Volume", NULL };
  290. struct Gadget DRXGGadget5 = {
  291.   &DRXGGadget4, 70, 92, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  292.   (APTR)&DRXGImage5, NULL, &DRXGText5, NULL, (APTR)&DRXGGadget5SInfo, LEVEL_GADGET, NULL };
  293.  
  294. // ALTERNATE gadget.
  295. struct PropInfo DRXGGadget6SInfo = {
  296.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY * 1/128, -1, };
  297. struct Image DRXGImage6 = {
  298.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  299. struct IntuiText DRXGText6 = {
  300.   2, 0, JAM1, -65, 1, NULL, "Altnate", NULL };
  301. struct Gadget DRXGGadget6 = {
  302.   &DRXGGadget5, 70, 102, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  303.   (APTR)&DRXGImage6, NULL, &DRXGText6, NULL, (APTR)&DRXGGadget6SInfo, ALTERNATE_GADGET, NULL };
  304.  
  305. // PANPOT gadget.
  306. struct PropInfo DRXGGadget7SInfo = {
  307.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY * 1/128 , -1, };
  308. struct Image DRXGImage7 = {
  309.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  310. struct IntuiText DRXGText7 = {
  311.   2, 0, JAM1, -65, 1, NULL, " Panpot", NULL };
  312. struct Gadget DRXGGadget7 = {
  313.   &DRXGGadget6, 70, 112, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  314.   (APTR)&DRXGImage7, NULL, &DRXGText7, NULL, (APTR)&DRXGGadget7SInfo, PAN_GADGET, NULL };
  315.  
  316. // REVERB gadget.
  317. struct PropInfo DRXGGadget8SInfo = {
  318.   AUTOKNOB+FREEHORIZ, 0, -1,  MAXBODY * 1/128 , -1, };
  319. struct Image DRXGImage8 = {
  320.   0, 0, 10, 6, 0, NULL, 0x0000, 0x0000, NULL };
  321. struct IntuiText DRXGText8 = {
  322.   2, 0, JAM1, -65, 1, NULL, " Reverb", NULL };
  323. struct Gadget DRXGGadget8 = {
  324.   &DRXGGadget7, 70, 122, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  325.   (APTR)&DRXGImage8, NULL, &DRXGText8, NULL, (APTR)&DRXGGadget8SInfo, REVERB_GADGET, NULL };
  326.  
  327. // CHORUS Gadget
  328. struct PropInfo DRXGGadget9Info = {
  329.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  330. struct Image DRXGImage9 = {
  331.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  332. struct IntuiText DRXGText9 = {
  333.   2, 0, JAM1, -65, 1, NULL, " Chorus", NULL };
  334. struct Gadget DRXGGadget9 = {
  335.   &DRXGGadget8, 70, 132, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  336.   (APTR)&DRXGImage9, NULL, &DRXGText9, NULL, (APTR)&DRXGGadget9Info, CHORUS_GADGET, NULL };
  337.  
  338. // VARFX gadget
  339. struct PropInfo DRXGGadget10Info = {
  340.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  341. struct Image DRXGImage10 = {
  342.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  343. struct IntuiText DRXGText10 = {
  344.   2, 0, JAM1, -65, 1, NULL, "  VarFX", NULL };
  345. struct Gadget DRXGGadget10 = {
  346.   &DRXGGadget9, 70, 142, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  347.   (APTR)&DRXGImage10, NULL, &DRXGText10, NULL, (APTR)&DRXGGadget10Info, VARFX_GADGET, NULL };
  348.  
  349. // KEYASSIGN Gadget
  350. struct PropInfo DRXGGadget11Info = {
  351.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/2,  -1, };
  352. struct Image DRXGImage11 = {
  353.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  354. struct IntuiText DRXGText11 = {
  355.   2, 0, JAM1, -45, 1, NULL, "KAsgn", NULL };
  356. struct Gadget DRXGGadget11 = {
  357.   &DRXGGadget10, 320, 72, 20, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  358.   (APTR)&DRXGImage11, NULL, &DRXGText11, NULL, (APTR)&DRXGGadget11Info, KEYASSIGN_GADGET, NULL };
  359.  
  360. // RCVNOTEOFF Gadget
  361. struct PropInfo DRXGGadget12Info = {
  362.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/2,  -1, };
  363. struct Image DRXGImage12 = {
  364.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  365. struct IntuiText DRXGText12 = {
  366.   2, 0, JAM1, -45, 1, NULL, "RNoff", NULL };
  367. struct Gadget DRXGGadget12 = {
  368.   &DRXGGadget11, 320, 82, 20, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  369.   (APTR)&DRXGImage12, NULL, &DRXGText12, NULL, (APTR)&DRXGGadget12Info, RCVNOTEOFF_GADGET, NULL };
  370.  
  371. // RCVNOTEON Gadget
  372. struct PropInfo DRXGGadget13Info = {
  373.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/2,  -1, };
  374. struct Image DRXGImage13 = {
  375.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  376. struct IntuiText DRXGText13 = {
  377.   2, 0, JAM1, -45, 1, NULL, "RvNon", NULL };
  378. struct Gadget DRXGGadget13 = {
  379.   &DRXGGadget12, 320, 92, 20, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  380.   (APTR)&DRXGImage13, NULL, &DRXGText13, NULL, (APTR)&DRXGGadget13Info, RCVNOTEON_GADGET, NULL };
  381.  
  382. // FICUTOFFREQ Gadget
  383. struct PropInfo DRXGGadget14Info = {
  384.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  385. struct Image DRXGImage14 = {
  386.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  387. struct IntuiText DRXGText14 = {
  388.   2, 0, JAM1, -65, 1, NULL, "FCutoff", NULL };
  389. struct Gadget DRXGGadget14 = {
  390.   &DRXGGadget13, 70, 162, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  391.   (APTR)&DRXGImage14, NULL, &DRXGText14, NULL, (APTR)&DRXGGadget14Info, FICUTOFFREQ_GADGET, NULL };
  392.  
  393. // FIRESON Gadget
  394. struct PropInfo DRXGGadget15Info = {
  395.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  396. struct Image DRXGImage15 = {
  397.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  398. struct IntuiText DRXGText15 = {
  399.   2, 0, JAM1, -65, 1, NULL, "FiReson", NULL };
  400. struct Gadget DRXGGadget15 = {
  401.   &DRXGGadget14, 70, 172, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  402.   (APTR)&DRXGImage15, NULL, &DRXGText15, NULL, (APTR)&DRXGGadget15Info, FICUTOFFRESON_GADGET, NULL };
  403.  
  404. // ATTACK Gadget
  405. struct PropInfo DRXGGadget16Info = {
  406.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  407. struct Image DRXGImage16 = {
  408.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  409. struct IntuiText DRXGText16 = {
  410.   2, 0, JAM1, -65, 1, NULL, " Attack", NULL };
  411. struct Gadget DRXGGadget16 = {
  412.   &DRXGGadget15, 70, 182, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  413.   (APTR)&DRXGImage16, NULL, &DRXGText16, NULL, (APTR)&DRXGGadget16Info, ATTACK_GADGET, NULL };
  414.  
  415. // DECAYA Gadget
  416. struct PropInfo DRXGGadget17Info = {
  417.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  418. struct Image DRXGImage17 = {
  419.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  420. struct IntuiText DRXGText17 = {
  421.   2, 0, JAM1, -65, 1, NULL, "Decay 1", NULL };
  422. struct Gadget DRXGGadget17 = {
  423.   &DRXGGadget16, 70, 192, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  424.   (APTR)&DRXGImage17, NULL, &DRXGText17, NULL, (APTR)&DRXGGadget17Info, DECAYA_GADGET, NULL };
  425.  
  426. // DECAYB Gadget
  427. struct PropInfo DRXGGadget18Info = {
  428.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/128,  -1, };
  429. struct Image DRXGImage18 = {
  430.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  431. struct IntuiText DRXGText18 = {
  432.   2, 0, JAM1, -65, 1, NULL, "Decay 2", NULL };
  433. struct Gadget DRXGGadget18 = {
  434.   &DRXGGadget17, 70, 202, 157, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  435.   (APTR)&DRXGImage18, NULL, &DRXGText18, NULL, (APTR)&DRXGGadget18Info, DECAYB_GADGET, NULL };
  436.  
  437. // VXON Gadget
  438. struct PropInfo DRXGGadget19Info = {
  439.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/2,  -1, };
  440. struct Image DRXGImage19 = {
  441.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  442. struct IntuiText DRXGText19 = {
  443.   2, 0, JAM1, 19, 1, NULL, "VFX:", NULL };
  444. struct Gadget DRXGGadget19 = {
  445.   &DRXGGadget18, 275, 142, 15, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  446.   (APTR)&DRXGImage19, NULL, &DRXGText19, NULL, (APTR)&DRXGGadget19Info, VXON_GADGET, NULL };
  447.  
  448. // DRUMSET Gadget
  449. struct PropInfo DRXGGadget20Info = {
  450.   AUTOKNOB+FREEHORIZ, 0,  -1, MAXBODY * 1/2,  -1, };
  451. struct Image DRXGImage20 = {
  452.   0, 0, 102, 6, 0, NULL, 0x0000, 0x0000, NULL };
  453. struct IntuiText DRXGText20 = {
  454.   2, 0, JAM1, -35, 1, NULL, "DSet", NULL };
  455. struct Gadget DRXGGadget20 = {
  456.   &DRXGGadget19, 40, 24, 13, 8, GFLG_GADGHBOX|GFLG_GADGHIMAGE, RELVERIFY|GADGIMMEDIATE, PROPGADGET,
  457.   (APTR)&DRXGImage20, NULL, &DRXGText20, NULL, (APTR)&DRXGGadget20Info, DRUMSET_GADGET, NULL };
  458.  
  459.  
  460. // Write gadget.
  461. struct IntuiText DRXGIText21 = {
  462.   4,0,JAM1,12,2,NULL,"Write",NULL
  463.   };
  464. struct Gadget DRXGGadget21 = {
  465.   &DRXGGadget20,300, 187, 65,11,GFLG_GADGHBOX|GFLG_GADGHIMAGE,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  466.   (APTR)NULL,NULL,&DRXGIText21,NULL,NULL,WRITE_GADGET,NULL
  467.   };
  468.  
  469. // Default gadget.
  470. struct IntuiText DRXGIText22 = {
  471.   4,0,JAM1,4,2,NULL,"Default",NULL
  472.   };
  473. struct Gadget DRXGGadget22 = {
  474.   &DRXGGadget21,300, 174, 65,11,GFLG_GADGHBOX|GFLG_GADGHIMAGE,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,
  475.   (APTR)NULL,NULL,&DRXGIText22,NULL,NULL,DEFAULT_GADGET,NULL
  476.   };
  477.  
  478.  
  479. //the mainwindowstructure
  480. struct NewWindow DRXGNewWindowStructure1 = {
  481.   0, 10,
  482.   407,  220,
  483.   0, 6,
  484.   GADGETDOWN|GADGETUP|CLOSEWINDOW,
  485.   WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|ACTIVATE|NOCAREREFRESH,
  486.   &DRXGGadget22,
  487.   NULL,
  488.   "XG Drum Editor",
  489.   NULL,
  490.   NULL,
  491.   5, 5,
  492.   -1, -1,
  493.   CUSTOMSCREEN
  494. };
  495.  
  496. extern struct ExecBase * SysBase;
  497. UBYTE  instrm,  kitnr;
  498.  
  499. struct DRXGTool {
  500.   struct Tool tool;
  501.  
  502.   UBYTE kit;
  503.   UBYTE instrument;
  504.   UBYTE pitchcourse;
  505.   UBYTE pitchfine;
  506.   UBYTE level;
  507.   UBYTE alternate;
  508.   UBYTE pan;
  509.   UBYTE reverb;
  510.   UBYTE chorus;
  511.   UBYTE varfx;
  512.   UBYTE keyassign;
  513.   UBYTE rcvnoteoff;
  514.   UBYTE rcvnoteon;
  515.   UBYTE ficutoffreq;
  516.   UBYTE ficutoffreson;
  517.   UBYTE attack;
  518.   UBYTE decaya;
  519.   UBYTE decayb;
  520.   UBYTE vxon;
  521.   UBYTE drumset;
  522.  
  523.   UBYTE writesw[1580];
  524.   UBYTE valstorage[1580];
  525.  
  526.   UBYTE msba;
  527.   UBYTE msbb;
  528.  
  529.   char *kitsysex;
  530.   char *instrumentsysex;
  531.   char *pitchcoursesysex;
  532.   char *pitchfinesysex;
  533.   char *levelsysex;
  534.   char *alternatesysex;
  535.   char *pansysex;
  536.   char *reverbsysex;
  537.   char *chorussysex;
  538.   char *varfxsysex;
  539.   char *keyassignsysex;
  540.   char *rcvnoteoffsysex;
  541.   char *rcvnoteonsysex;
  542.   char *ficutoffreqsysex;
  543.   char *ficutoffresonsysex;
  544.   char *attacksysex;
  545.   char *decayasysex;
  546.   char *decaybsysex;
  547.   char *vxonsysex;
  548.   char *drumsetsysex;
  549.  
  550.   char *msbasysex;
  551.   char *msbbsysex;
  552.  
  553. };
  554.  
  555. static struct ToolMaster master;
  556.  
  557. extern struct Functions *functions;
  558.  
  559. //initial values
  560. static void DRXG_tool_init(struct DRXGTool *tool)
  561. {
  562.   int b;
  563.   tool->valstorage[0]   = initstorage[0];
  564.   tool->valstorage[1]   = initstorage[1];
  565.   tool->valstorage[19]  = initstorage[19];
  566.  
  567.   for (b=0; b<=78 ;b++)
  568.   {
  569.   tool->valstorage[(b*20)+2]   = initstorage[(b*20)+2];
  570.   tool->valstorage[(b*20)+3]   = initstorage[(b*20)+3];
  571.   tool->valstorage[(b*20)+4]   = initstorage[(b*20)+4];
  572.   tool->valstorage[(b*20)+5]   = initstorage[(b*20)+5];
  573.   tool->valstorage[(b*20)+6]   = initstorage[(b*20)+6];
  574.   tool->valstorage[(b*20)+7]   = initstorage[(b*20)+7];
  575.   tool->valstorage[(b*20)+8]   = initstorage[(b*20)+8];
  576.   tool->valstorage[(b*20)+9]   = initstorage[(b*20)+9];
  577.   tool->valstorage[(b*20)+10]  = initstorage[(b*20)+10];
  578.   tool->valstorage[(b*20)+11]  = initstorage[(b*20)+11];
  579.   tool->valstorage[(b*20)+12]  = initstorage[(b*20)+12];
  580.   tool->valstorage[(b*20)+13]  = initstorage[(b*20)+13];
  581.   tool->valstorage[(b*20)+14]  = initstorage[(b*20)+14];
  582.   tool->valstorage[(b*20)+15]  = initstorage[(b*20)+15];
  583.   tool->valstorage[(b*20)+16]  = initstorage[(b*20)+16];
  584.   tool->valstorage[(b*20)+17]  = initstorage[(b*20)+17];
  585.   tool->valstorage[(b*20)+18]  = initstorage[(b*20)+18];
  586.   }
  587.  
  588.   tool->tool.touched = TOUCH_INIT;
  589.  
  590.   tool->kit             = tool->valstorage[0];
  591.   tool->instrument      = tool->valstorage[1];
  592.   tool->pitchcourse     = tool->valstorage[2];
  593.   tool->pitchfine       = tool->valstorage[3];
  594.   tool->level           = tool->valstorage[4];
  595.   tool->alternate       = tool->valstorage[5];
  596.   tool->pan             = tool->valstorage[6];
  597.   tool->reverb          = tool->valstorage[7];
  598.   tool->chorus          = tool->valstorage[8];
  599.   tool->varfx           = tool->valstorage[9];
  600.   tool->keyassign       = tool->valstorage[10];
  601.   tool->rcvnoteoff      = tool->valstorage[11];
  602.   tool->rcvnoteon       = tool->valstorage[12];
  603.   tool->ficutoffreq     = tool->valstorage[13];
  604.   tool->ficutoffreson   = tool->valstorage[14];
  605.   tool->attack          = tool->valstorage[15];
  606.   tool->decaya          = tool->valstorage[16];
  607.   tool->decayb          = tool->valstorage[17];
  608.   tool->vxon            = tool->valstorage[18];
  609.   tool->drumset         = tool->valstorage[19];
  610.  
  611.   tool->msba            = 0;
  612.   tool->msbb            = 0;
  613.  
  614.   tool->kitsysex            = NULL;
  615.   tool->instrumentsysex     = NULL;
  616.   tool->pitchcoursesysex    = NULL;
  617.   tool->pitchfinesysex      = NULL;
  618.   tool->levelsysex          = NULL;
  619.   tool->alternatesysex      = NULL;
  620.   tool->pansysex            = NULL;
  621.   tool->reverbsysex         = NULL;
  622.   tool->chorussysex         = NULL;
  623.   tool->varfxsysex          = NULL;
  624.   tool->keyassignsysex      = NULL;
  625.   tool->rcvnoteoffsysex     = NULL;
  626.   tool->rcvnoteonsysex      = NULL;
  627.   tool->ficutoffreqsysex    = NULL;
  628.   tool->ficutoffresonsysex  = NULL;
  629.   tool->attacksysex         = NULL;
  630.   tool->decayasysex         = NULL;
  631.   tool->decaybsysex         = NULL;
  632.   tool->vxonsysex           = NULL;
  633.   tool->drumsetsysex        = NULL;
  634.  
  635.   tool->msbasysex            = NULL;
  636.   tool->msbbsysex            = NULL;
  637.  
  638.   for (b=0; b<=1580; b++)
  639.       {tool->writesw[b]=0;}
  640.  
  641. }
  642.  
  643.  
  644.  
  645. static struct Event * __saveds processeventcode(struct Event *event)
  646. {
  647.   event->tool = event->tool->next;
  648.   return(event);
  649. }
  650.  
  651. static BOOL lock_clip(struct Clip *clip)
  652. {
  653.   Forbid();
  654.   if (clip->locked == 0)
  655.     {
  656.       clip->locked = 1;
  657.       Permit();
  658.       return TRUE;
  659.     }
  660.   else
  661.     {
  662.       Permit();
  663.       return FALSE;
  664.     }
  665. }
  666.  
  667. static void unlock_clip(struct Clip *clip)
  668. {
  669.   clip->locked = 0;
  670. }
  671.  
  672. //writes sysex into track
  673.  
  674. static void __saveds insertsysex(char *buff, short size, struct DRXGTool *tool,  const LONG time)
  675. {
  676.     struct StringEvent *event;
  677.     struct String *string;
  678.  
  679.     event = (struct StringEvent *) (*functions->allocevent)();
  680.      if (event)
  681.       {
  682.         string = (struct String *) (*functions->myalloc)(size + 3, MEMF_CLEAR);
  683.         if (string)
  684.         {
  685.             event->next = NULL;
  686.             event->string = string;
  687.             memcpy(string->string,  buff,  size);
  688.             string->length = size + 2;
  689.             event->type = EVENT_SYSX;
  690.             event->status = MIDI_SYSX;
  691.             event->time = time;
  692.             event->tool = tool->tool.next;
  693.             if (lock_clip(&(tool->tool.track->clip)))
  694.               {
  695.                 event->next = (struct StringEvent *)tool->tool.track->clip.events.first;
  696.                 tool->tool.track->clip.events.first = (struct Event *)(*functions->sorteventlist)(event);
  697.                 unlock_clip(&(tool->tool.track->clip));
  698.               }
  699.             else
  700.               {
  701.                 (*functions->freelist)(event);
  702.               }
  703.  
  704.         }
  705.       }
  706.  
  707. }
  708.  
  709. // initialize the VarfxON
  710. static void __saveds initvx(struct DRXGTool *tool, const LONG time)
  711. {
  712. struct Event *vxevent = (struct Event *)(*functions->allocevent)();
  713.      if (vxevent)
  714.      {
  715.       vxevent->type = EVENT_VOICE;
  716.       vxevent->status = MIDI_CCHANGE;
  717.       vxevent->byte1 = 94;
  718.       vxevent->byte2 = 100;
  719.       vxevent->time = time;
  720.       vxevent->next = NULL;
  721.       vxevent->tool = tool->tool.next;
  722.       (*functions->qevent)(vxevent);
  723.       }
  724. }
  725.  
  726. // the routine for sending SysEx-data thru the pipeline
  727.  
  728. static void __saveds sendsysex(char *buff,  short size,  struct DRXGTool *tool,  const LONG time)
  729. {
  730.     struct StringEvent *event;
  731.     struct String *string;
  732.  
  733.     event = (struct StringEvent *) (*functions->allocevent)();
  734.      if (event)
  735.       {
  736.         string = (struct String *) (*functions->myalloc)(size + 3, MEMF_CLEAR);
  737.         if (string)
  738.         {
  739.             event->string = string;
  740.             memcpy(string->string,  buff,  size);
  741.             string->length = size + 2;
  742.             event->type = EVENT_SYSX;
  743.             event->status = MIDI_SYSX;
  744.             event->time = time;
  745.             event->tool = tool->tool.next;
  746.             WaitTOF();
  747.             (*functions->qevent)(event);
  748.             (*functions->myfree)(string);
  749.         }
  750.       }
  751.  
  752. }
  753.  
  754. static void __saveds trans_hx(struct DRXGTool *tool,  const LONG time,  char *sysx, int sw)
  755. {
  756.   LONG size;
  757.   int a,  b,  x,  y ;
  758.   UBYTE abuf[32];
  759.   char chr[4];
  760.   char *zbuf = NULL;
  761.   struct Event *sysx_event;
  762.  
  763.     //translate sysexbuffer into hex
  764.  
  765.   size = strlen(sysx);
  766.   zbuf = (char *)AllocVec(size+2,  MEMF_ANY|MEMF_CLEAR);
  767.   if(zbuf)
  768.      {
  769.        CopyMem(sysx,  zbuf,  size);
  770.        b=0;
  771.        for(a=0;a < size;a=a+2)
  772.            {
  773.              chr[0] = zbuf[a];
  774.              chr[1] = zbuf[a+1];
  775.  
  776.              x=(isdigit((int)chr[0]))? (chr[0]&0xF) : ((chr[0]&0xDF)-55); //this is the
  777.              y=(isdigit((int)chr[1]))? (chr[1]&0xF) : ((chr[1]&0xDF)-55); //the translate-core
  778.  
  779.              abuf[b++] = ((x<<4)|y);   //writing with bitmanipulation
  780.             }
  781.       //send hexdata
  782.  
  783.        FreeVec(zbuf);
  784.        if (sw == 0) sendsysex(abuf,  b,  tool,  time);
  785.        if (sw == 1) insertsysex(abuf,  b,  tool,  time);
  786.  
  787.      }
  788.  
  789. }
  790.  
  791. //to put all the sliders to the value, that's stored
  792. void initslider(struct DRXGTool *tool, struct Window *window)
  793. {
  794.   int i, b, a = (tool->valstorage[1]-13)*20;
  795.  
  796.   tool->pitchcourse     = tool->valstorage[2+a] ;
  797.   tool->pitchfine       = tool->valstorage[3+a] ;
  798.   tool->level           = tool->valstorage[4+a] ;
  799.   tool->alternate       = tool->valstorage[5+a] ;
  800.   tool->pan             = tool->valstorage[6+a] ;
  801.   tool->reverb          = tool->valstorage[7+a] ;
  802.   tool->chorus          = tool->valstorage[8+a] ;
  803.   tool->varfx           = tool->valstorage[9+a] ;
  804.   tool->keyassign       = tool->valstorage[10+a];
  805.   tool->rcvnoteoff      = tool->valstorage[11+a];
  806.   tool->rcvnoteon       = tool->valstorage[12+a];
  807.   tool->ficutoffreq     = tool->valstorage[13+a];
  808.   tool->ficutoffreson   = tool->valstorage[14+a];
  809.   tool->attack          = tool->valstorage[15+a];
  810.   tool->decaya          = tool->valstorage[16+a];
  811.   tool->decayb          = tool->valstorage[17+a];
  812.   tool->vxon            = tool->valstorage[18];
  813.  
  814.   (*functions->ModifyEmbossedProp)(window, PITCHCOURSE_GADGET   , tool->pitchcourse, 0,  0,  0,  0,  0);
  815.   (*functions->ModifyEmbossedProp)(window, PITCHFINE_GADGET     , tool->pitchfine,  0,  0,  0,  0,  0);
  816.   (*functions->ModifyEmbossedProp)(window, LEVEL_GADGET         , tool->level,  0,  0,  0,  0,  0);
  817.   (*functions->ModifyEmbossedProp)(window, ALTERNATE_GADGET     , tool->alternate,  0,  0,  0,  0,  0);
  818.   (*functions->ModifyEmbossedProp)(window, PAN_GADGET           , tool->pan,  0,  0,  0,  0,  0);
  819.   (*functions->ModifyEmbossedProp)(window, REVERB_GADGET        , tool->reverb,  0,  0,  0,  0,  0);
  820.   (*functions->ModifyEmbossedProp)(window, CHORUS_GADGET        , tool->chorus,  0,  0,  0,  0,  0);
  821.   (*functions->ModifyEmbossedProp)(window, VARFX_GADGET         , tool->varfx,  0,  0,  0,  0,  0);
  822.   (*functions->ModifyEmbossedProp)(window, KEYASSIGN_GADGET     , tool->keyassign,  0,  0,  0,  0,  0);
  823.   (*functions->ModifyEmbossedProp)(window, RCVNOTEOFF_GADGET    , tool->rcvnoteoff,  0,  0,  0,  0,  0);
  824.   (*functions->ModifyEmbossedProp)(window, RCVNOTEON_GADGET     , tool->rcvnoteon,  0,  0,  0,  0,  0);
  825.   (*functions->ModifyEmbossedProp)(window, FICUTOFFREQ_GADGET   , tool->ficutoffreq,  0,  0,  0,  0,  0);
  826.   (*functions->ModifyEmbossedProp)(window, FICUTOFFRESON_GADGET , tool->ficutoffreson,  0,  0,  0,  0,  0);
  827.   (*functions->ModifyEmbossedProp)(window, ATTACK_GADGET        , tool->attack,  0,  0,  0,  0,  0);
  828.   (*functions->ModifyEmbossedProp)(window, DECAYA_GADGET        , tool->decaya,  0,  0,  0,  0,  0);
  829.   (*functions->ModifyEmbossedProp)(window, DECAYB_GADGET        , tool->decayb,  0,  0,  0,  0,  0);
  830.   (*functions->ModifyEmbossedProp)(window, VXON_GADGET          , tool->vxon,  0,  0,  0,  0,  0);
  831.  
  832.  for (i= PITCHCOURSE_GADGET; i<=VXON_GADGET ; i++)
  833.      {
  834.         (*functions->DrawEmbossedProp)(window,  i);
  835.      }
  836.  
  837. }
  838.  
  839. //to put all the sliders to the default values
  840. void defaultslider(struct DRXGTool *tool, struct Window *window)
  841. {
  842.   int i, b;
  843.   LONG time, a = ((tool->valstorage[1])-13)*20;
  844.   char storage1[32];
  845.   char storage2[32];
  846.   char storage3[32];
  847.   char storage4[32];
  848.   char storage5[32];
  849.   char storage6[32];
  850.   char storage7[32];
  851.   char storage8[32];
  852.   char storage9[32];
  853.   char storage10[32];
  854.   char storage11[32];
  855.   char storage12[32];
  856.   char storage13[32];
  857.   char storage14[32];
  858.   char storage15[32];
  859.   char storage16[32];
  860.   char storage17[32];
  861.  
  862.    tool->valstorage[2+a]  =  initstorage[a+2];
  863.    tool->valstorage[3+a]  =  initstorage[a+3];
  864.    tool->valstorage[4+a]  =  initstorage[a+4];
  865.    tool->valstorage[5+a]  =  initstorage[a+5];
  866.    tool->valstorage[6+a]  =  initstorage[a+6];
  867.    tool->valstorage[7+a]  =  initstorage[a+7];
  868.    tool->valstorage[8+a]  =  initstorage[a+8];
  869.    tool->valstorage[9+a]  =  initstorage[a+9];
  870.    tool->valstorage[10+a] =  initstorage[a+10];
  871.    tool->valstorage[11+a] =  initstorage[a+11];
  872.    tool->valstorage[12+a] =  initstorage[a+12];
  873.    tool->valstorage[13+a] =  initstorage[a+13];
  874.    tool->valstorage[14+a] =  initstorage[a+14];
  875.    tool->valstorage[15+a] =  initstorage[a+15];
  876.    tool->valstorage[16+a] =  initstorage[a+16];
  877.    tool->valstorage[17+a] =  initstorage[a+17];
  878.    tool->valstorage[18+a] =  initstorage[a+18];
  879.  
  880.   tool->pitchcourse     = tool->valstorage[2+a] ;
  881.   tool->pitchfine       = tool->valstorage[3+a] ;
  882.   tool->level           = tool->valstorage[4+a] ;
  883.   tool->alternate       = tool->valstorage[5+a] ;
  884.   tool->pan             = tool->valstorage[6+a] ;
  885.   tool->reverb          = tool->valstorage[7+a] ;
  886.   tool->chorus          = tool->valstorage[8+a] ;
  887.   tool->varfx           = tool->valstorage[9+a] ;
  888.   tool->keyassign       = tool->valstorage[10+a];
  889.   tool->rcvnoteoff      = tool->valstorage[11+a];
  890.   tool->rcvnoteon       = tool->valstorage[12+a];
  891.   tool->ficutoffreq     = tool->valstorage[13+a];
  892.   tool->ficutoffreson   = tool->valstorage[14+a];
  893.   tool->attack          = tool->valstorage[15+a];
  894.   tool->decaya          = tool->valstorage[16+a];
  895.   tool->decayb          = tool->valstorage[17+a];
  896.   tool->vxon            = tool->valstorage[18];
  897.  
  898. for (b=2; b<=18; b++)
  899.     {tool->writesw[b+a]=0;}
  900.  
  901.   (*functions->ModifyEmbossedProp)(window, PITCHCOURSE_GADGET   , tool->pitchcourse, 0,  0,  0,  0,  0);
  902.   (*functions->ModifyEmbossedProp)(window, PITCHFINE_GADGET     , tool->pitchfine,  0,  0,  0,  0,  0);
  903.   (*functions->ModifyEmbossedProp)(window, LEVEL_GADGET         , tool->level,  0,  0,  0,  0,  0);
  904.   (*functions->ModifyEmbossedProp)(window, ALTERNATE_GADGET     , tool->alternate,  0,  0,  0,  0,  0);
  905.   (*functions->ModifyEmbossedProp)(window, PAN_GADGET           , tool->pan,  0,  0,  0,  0,  0);
  906.   (*functions->ModifyEmbossedProp)(window, REVERB_GADGET        , tool->reverb,  0,  0,  0,  0,  0);
  907.   (*functions->ModifyEmbossedProp)(window, CHORUS_GADGET        , tool->chorus,  0,  0,  0,  0,  0);
  908.   (*functions->ModifyEmbossedProp)(window, VARFX_GADGET         , tool->varfx,  0,  0,  0,  0,  0);
  909.   (*functions->ModifyEmbossedProp)(window, KEYASSIGN_GADGET     , tool->keyassign,  0,  0,  0,  0,  0);
  910.   (*functions->ModifyEmbossedProp)(window, RCVNOTEOFF_GADGET    , tool->rcvnoteoff,  0,  0,  0,  0,  0);
  911.   (*functions->ModifyEmbossedProp)(window, RCVNOTEON_GADGET     , tool->rcvnoteon,  0,  0,  0,  0,  0);
  912.   (*functions->ModifyEmbossedProp)(window, FICUTOFFREQ_GADGET   , tool->ficutoffreq,  0,  0,  0,  0,  0);
  913.   (*functions->ModifyEmbossedProp)(window, FICUTOFFRESON_GADGET , tool->ficutoffreson,  0,  0,  0,  0,  0);
  914.   (*functions->ModifyEmbossedProp)(window, ATTACK_GADGET        , tool->attack,  0,  0,  0,  0,  0);
  915.   (*functions->ModifyEmbossedProp)(window, DECAYA_GADGET        , tool->decaya,  0,  0,  0,  0,  0);
  916.   (*functions->ModifyEmbossedProp)(window, DECAYB_GADGET        , tool->decayb,  0,  0,  0,  0,  0);
  917.   (*functions->ModifyEmbossedProp)(window, VXON_GADGET          , tool->vxon,  0,  0,  0,  0,  0);
  918.  
  919.  for (i= PITCHCOURSE_GADGET; i<=VXON_GADGET ; i++)
  920.      {
  921.         (*functions->DrawEmbossedProp)(window,  i);
  922.      }
  923.  
  924.               sprintf(storage1, "F043104C3%1lx%02lx00%02lxF7",tool->drumset,tool->valstorage[1],tool->pitchcourse);
  925.               tool->pitchcoursesysex = storage1;
  926.               time = functions->timenow;
  927.               trans_hx(tool,  time,  tool->pitchcoursesysex, 0);
  928.  
  929.               sprintf(storage2, "F043104C3%1lx%02lx01%02lxF7",tool->drumset,tool->valstorage[1],tool->pitchfine);
  930.               tool->pitchfinesysex = storage2;
  931.               time = functions->timenow;
  932.               trans_hx(tool,  time,  tool->pitchfinesysex, 0);
  933.  
  934.               sprintf(storage3, "F043104C3%1lx%02lx02%02lxF7",tool->drumset,tool->valstorage[1],tool->level);
  935.               tool->levelsysex = storage3;
  936.               time = functions->timenow;
  937.               trans_hx(tool,  time,  tool->levelsysex, 0);
  938.  
  939.               sprintf(storage4, "F043104C3%1lx%02lx03%02lxF7",tool->drumset,tool->valstorage[1],tool->alternate);
  940.               tool->alternatesysex = storage4;
  941.               time = functions->timenow;
  942.               trans_hx(tool,  time,  tool->alternatesysex, 0);
  943.  
  944.               sprintf(storage5, "F043104C3%1lx%02lx04%02lxF7",tool->drumset,tool->valstorage[1],tool->pan);
  945.               tool->pansysex = storage5;
  946.               time = functions->timenow;
  947.               trans_hx(tool,  time,  tool->pansysex, 0);
  948.  
  949.               sprintf(storage6, "F043104C3%1lx%02lx05%02lxF7",tool->drumset,tool->valstorage[1],tool->reverb);
  950.               tool->reverbsysex  = storage6;
  951.               time = functions->timenow;
  952.               trans_hx(tool,  time,  tool->reverbsysex, 0);
  953.  
  954.               sprintf(storage7, "F043104C3%1lx%02lx06%02lxF7",tool->drumset,tool->valstorage[1],tool->chorus);
  955.               tool->chorussysex      = storage7;
  956.               time = functions->timenow;
  957.               trans_hx(tool,  time,  tool->chorussysex, 0);
  958.  
  959.               sprintf(storage8, "F043104C3%1lx%02lx07%02lxF7",tool->drumset,tool->valstorage[1],tool->varfx);
  960.               tool->varfxsysex        = storage8;
  961.               time = functions->timenow;
  962.               trans_hx(tool,  time,  tool->varfxsysex, 0);
  963.  
  964.               sprintf(storage9, "F043104C3%1lx%02lx08%02lxF7",tool->drumset,tool->valstorage[1],tool->keyassign);
  965.               tool->keyassignsysex        = storage9;
  966.               time = functions->timenow;
  967.               trans_hx(tool,  time,  tool->keyassignsysex, 0);
  968.  
  969.               sprintf(storage10, "F043104C3%1lx%02lx09%02lxF7",tool->drumset,tool->valstorage[1],tool->rcvnoteoff);
  970.               tool->rcvnoteoffsysex         = storage10;
  971.               time = functions->timenow;
  972.               trans_hx(tool,  time,  tool->rcvnoteoffsysex, 0);
  973.  
  974.               sprintf(storage11, "F043104C3%1lx%02lx0A%02lxF7",tool->drumset,tool->valstorage[1],tool->rcvnoteon);
  975.               tool->rcvnoteonsysex      = storage11;
  976.               time = functions->timenow;
  977.               trans_hx(tool,  time,  tool->rcvnoteonsysex, 0);
  978.  
  979.               sprintf(storage12, "F043104C3%1lx%02lx0B%02lxF7",tool->drumset,tool->valstorage[1],tool->ficutoffreq);
  980.               tool->ficutoffreqsysex     = storage12;
  981.               time = functions->timenow;
  982.               trans_hx(tool,  time,  tool->ficutoffreqsysex, 0);
  983.  
  984.               sprintf(storage13, "F043104C3%1lx%02lx0C%02lxF7",tool->drumset,tool->valstorage[1],tool->ficutoffreson);
  985.               tool->ficutoffresonsysex     = storage13;
  986.               time = functions->timenow;
  987.               trans_hx(tool,  time,  tool->ficutoffresonsysex, 0);
  988.  
  989.               sprintf(storage14, "F043104C3%1lx%02lx0D%02lxF7",tool->drumset,tool->valstorage[1],tool->attack);
  990.               tool->attacksysex     = storage14;
  991.               time = functions->timenow;
  992.               trans_hx(tool,  time,  tool->attacksysex, 0);
  993.  
  994.               sprintf(storage15, "F043104C3%1lx%02lx0E%02lxF7",tool->drumset,tool->valstorage[1],tool->decaya);
  995.               tool->decayasysex     = storage15;
  996.               time = functions->timenow;
  997.               trans_hx(tool,  time,  tool->decayasysex, 0);
  998.  
  999.               sprintf(storage16, "F043104C3%1lx%02lx0F%02lxF7",tool->drumset,tool->valstorage[1],tool->decayb);
  1000.               tool->decaybsysex      = storage16;
  1001.               time = functions->timenow;
  1002.               trans_hx(tool,  time,  tool->decaybsysex, 0);
  1003.  
  1004.               sprintf(storage17, "F043104C02015A%02lxF7",tool->vxon);
  1005.               tool->vxonsysex     = storage17;
  1006.               time = functions->timenow;
  1007.               trans_hx(tool,  time,  tool->vxonsysex, 0);
  1008.  
  1009.  
  1010. }
  1011.  
  1012.  
  1013. // Writes all values of the sliders and more  in the main window
  1014.  
  1015. LONG __saveds display_routine(struct Window *window, struct Gadget *gadget, ULONG value)
  1016. {
  1017.   char text[32];
  1018.   char tname[32];
  1019.  
  1020.   const short id = gadget->GadgetID;
  1021.   struct RastPort *rp = window->RPort;
  1022.   int  i=0;
  1023.   char kit[11][11]=
  1024.   {
  1025.     "Standard 1 ", "Standard 2 ", "Rock Kit   ", "Room Kit   ", "Electro Kit", "Analog Kit ",
  1026.     "Jazz Kit   ", "Brush Kit  ", "Classic Kit", "SFX 1      ", "SFX 2      "};
  1027.  
  1028.   char note[79][4]={
  1029.          "C#-1"," D-1","D#-1"," E-1"," F-1","F#-1"," G-1","G#-1"," A-1","A#-1"," B-1",
  1030.   "  C0"," C#0","  D0"," D#0","  E0","  F0"," F#0","  G0"," G#0","  A0"," A#0","  B0",
  1031.   "  C1"," C#1","  D1"," D#1","  E1","  F1"," F#1","  G1"," G#1","  A1"," A#1","  B1",
  1032.   "  C2"," C#2","  D2"," D#2","  E2","  F2"," F#2","  G2"," G#2","  A2"," A#2","  B2",
  1033.   "  C3"," C#3","  D3"," D#3","  E3","  F3"," F#3","  G3"," G#3","  A3"," A#3","  B3",
  1034.   "  C4"," C#4","  D4"," D#4","  E4","  F4"," F#4","  G4"," G#4","  A4"," A#4","  B4",
  1035.   "  C5"," C#5","  D5"," D#5","  E5","  F5"," F#5","  G5"};
  1036.  
  1037.   char keas[2][6]={"Single","Multi "};
  1038.   char on[3][3]={"off","on ","rdm"};
  1039.  
  1040.   SetAPen(rp,  6);
  1041.   SetBPen(rp,  0);
  1042.   SetDrMd(rp,  JAM2);
  1043.  
  1044.          switch (id)
  1045.               {
  1046.               case KIT_GADGET:
  1047.                 kitnr = value;
  1048.                 sprintf(text,  "%.11s",  kit[value]);
  1049.                 Move(rp, 238,  58);
  1050.                 Text(rp,  text,  11);
  1051.                 break;
  1052.               case INSTRUMENT_GADGET:
  1053.                 instrm = (value+13);
  1054.                 sprintf(text,  "%.4s",  note[value]);
  1055.                 Move(rp, 238,  48);
  1056.                 Text(rp,  text,  4);
  1057.                 break;
  1058.               case PITCHCOURSE_GADGET:
  1059.                 Move(rp,  238,  78);
  1060.                 sprintf(text,  "%3ld",  value);
  1061.                 Text(rp,  text,  3);
  1062.                 break;
  1063.               case PITCHFINE_GADGET:
  1064.                 Move(rp,  238,  88);
  1065.                 sprintf(text,  "%3ld",  value);
  1066.                 Text(rp,  text,  3);
  1067.                 break;
  1068.               case LEVEL_GADGET:
  1069.                 Move(rp,  238,  98);
  1070.                 sprintf(text,  "%3ld",  value);
  1071.                 Text(rp,  text,  3);
  1072.                 break;
  1073.               case ALTERNATE_GADGET:
  1074.                 if (value == 0)
  1075.                     {
  1076.                     Move(rp,  238,  108);
  1077.                     sprintf(text,  "%.3s",  on[value]);
  1078.                     Text(rp,  text,  3);
  1079.                     }
  1080.                 else
  1081.                     {
  1082.                     Move(rp,  238,  108);
  1083.                     sprintf(text,  "%3ld",  value);
  1084.                     Text(rp,  text,  3);
  1085.                     }
  1086.                 break;
  1087.               case PAN_GADGET:
  1088.                 if (value == 0)
  1089.                     {
  1090.                     Move(rp,  238,  118);
  1091.                     sprintf(text,  "%.3s",  on[2]);
  1092.                     Text(rp,  text,  3);
  1093.                     }
  1094.                 else
  1095.                     {
  1096.                     Move(rp,  238,  118);
  1097.                     sprintf(text,  "%3ld",  value);
  1098.                     Text(rp,  text,  3);
  1099.                     }
  1100.                 break;
  1101.               case REVERB_GADGET:
  1102.                 Move(rp,  238,  128);
  1103.                 sprintf(text,  "%3ld",  value);
  1104.                 Text(rp,  text,  3);
  1105.                 break;
  1106.              case CHORUS_GADGET:
  1107.                 Move(rp, 238,  138);
  1108.                 sprintf(text,  "%3ld",  value);
  1109.                 Text(rp,  text,  3);
  1110.                 break;
  1111.               case VARFX_GADGET:
  1112.                 Move(rp, 238,  148);
  1113.                 sprintf(text,  "%3ld",  value);
  1114.                 Text(rp,  text,  3);
  1115.                 break;
  1116.               case KEYASSIGN_GADGET:
  1117.                 Move(rp, 345,  78);
  1118.                 sprintf(text,  "%.6s",  keas[value]);
  1119.                 Text(rp,  text,  6);
  1120.                 break;
  1121.               case RCVNOTEOFF_GADGET:
  1122.                 Move(rp, 345,  88);
  1123.                 sprintf(text,  "%.3s",  on[value]);
  1124.                 Text(rp,  text,  3);
  1125.                 break;
  1126.               case RCVNOTEON_GADGET:
  1127.                 Move(rp, 345,  98);
  1128.                 sprintf(text,  "%.3s",  on[value]);
  1129.                 Text(rp,  text,  3);
  1130.                 break;
  1131.               case FICUTOFFREQ_GADGET:
  1132.                 Move(rp, 238,  168);
  1133.                 sprintf(text,  "%3ld",  value);
  1134.                 Text(rp,  text,  3);
  1135.                 break;
  1136.               case FICUTOFFRESON_GADGET:
  1137.                 Move(rp, 238,  178);
  1138.                 sprintf(text,  "%3ld",  value);
  1139.                 Text(rp,  text,  3);
  1140.                 break;
  1141.               case ATTACK_GADGET:
  1142.                 Move(rp, 238,  188);
  1143.                 sprintf(text,  "%3ld",  value);
  1144.                 Text(rp,  text,  3);
  1145.                 break;
  1146.               case DECAYA_GADGET:
  1147.                 Move(rp, 238,  198);
  1148.                 sprintf(text,  "%3ld",  value);
  1149.                 Text(rp,  text,  3);
  1150.                 break;
  1151.               case DECAYB_GADGET:
  1152.                 Move(rp, 238,  208);
  1153.                 sprintf(text,  "%3ld",  value);
  1154.                 Text(rp,  text,  3);
  1155.                 break;
  1156.               case VXON_GADGET: 
  1157.                 Move(rp, 325,  149);
  1158.                 sprintf(text,  "%.3s",  on[value]);
  1159.                 Text(rp,  text,  3);
  1160.                 break;
  1161.               case DRUMSET_GADGET:
  1162.                 Move(rp, 57,  30);
  1163.                 sprintf(text,  "%1ld",  value+1);
  1164.                 Text(rp,  text,  1);
  1165.                 break;
  1166.               default:
  1167.                 break;
  1168.               }
  1169.     sprintf(tname,  "Name:%25.25s",  (matrix[kitnr * MAX_INSTRUMENTS+instrm])?
  1170.                                       (char *)matrix[kitnr * MAX_INSTRUMENTS+instrm]:(char *)EMPTY);
  1171.     SetAPen(rp,  4);
  1172.     SetBPen(rp,  7);
  1173.     SetDrMd(rp,  INVERSVID|JAM2);
  1174.     Move(rp,  69,  30);
  1175.     Text(rp,  tname,  strlen(tname));
  1176. return (value);
  1177. }
  1178.  
  1179. //to hear the changes
  1180.  
  1181. static void send_note(struct DRXGTool *tool,  const long time,  const UBYTE note)
  1182. {
  1183.   struct NoteEvent *on_event = (struct NoteEvent *)(*functions->allocevent)();
  1184.   if (on_event)
  1185.     {
  1186.       struct NoteEvent *off_event = (struct NoteEvent *)(*functions->allocevent)();
  1187.       if (off_event)
  1188.         {
  1189.           on_event->next  =
  1190.           off_event->next = NULL;
  1191.  
  1192.           on_event->type  =
  1193.           off_event->type = EVENT_VOICE;
  1194.  
  1195.           on_event->status  = MIDI_NOTEON;
  1196.           off_event->status = MIDI_NOTEOFF;
  1197.  
  1198.           on_event->value  =
  1199.           off_event->value = note;
  1200.  
  1201.           on_event->velocity = 80;
  1202.  
  1203.           on_event->time  = time;
  1204.           off_event->time = time + 96;
  1205.  
  1206.           on_event->tool  =
  1207.           off_event->tool = tool->tool.next;
  1208.  
  1209.           (*functions->qevent)(on_event);
  1210.           (*functions->qevent)(off_event);
  1211.         }
  1212.       else
  1213.         {
  1214.           (*functions->freeevent)(on_event);
  1215.         }
  1216.     }
  1217. }
  1218.  
  1219. //the center off all
  1220.  
  1221. static void __saveds edittoolcode(struct DRXGTool *tool)
  1222. {
  1223.   struct IntuiMessage *message;
  1224.   struct Window *window;
  1225.   struct Event *msba_event;
  1226.   struct Event *msbb_event;
  1227.   struct Event *pc_event;
  1228.   LONG class,  code,  time;
  1229.   struct Gadget *gadget;
  1230.   struct NewWindow *newwindow;
  1231.   int i, b, c, a, revres=0;
  1232.   char *kittypebt;
  1233.   UBYTE kittypbyte[11] ={0, 1, 8, 16, 24, 32, 40, 70};
  1234.   char storage1[32];
  1235.   char storage2[32];
  1236.   char storage3[32];
  1237.   char storage4[32];
  1238.   char storage5[32];
  1239.   char storage6[32];
  1240.   char storage7[32];
  1241.   char storage8[32];
  1242.   char storage9[32];
  1243.   char storage10[32];
  1244.   char storage11[32];
  1245.   char storage12[32];
  1246.   char storage13[32];
  1247.   char storage14[32];
  1248.   char storage15[32];
  1249.   char storage16[32];
  1250.   char storage17[32];
  1251.   char storage18[32];
  1252.   char storage19[32];
  1253.   char storage20[32];
  1254.   char storage21[32];
  1255.  
  1256.   DRXGNewWindowStructure1.Screen = functions->screen;
  1257.  
  1258.   if (tool->tool.touched & TOUCH_EDIT)
  1259.     {
  1260.       DRXGNewWindowStructure1.LeftEdge = tool->tool.left;
  1261.       DRXGNewWindowStructure1.TopEdge = tool->tool.top;
  1262.       DRXGNewWindowStructure1.Width = tool->tool.width;
  1263.       DRXGNewWindowStructure1.Height = tool->tool.height;
  1264.     }
  1265.   
  1266.   if (!tool->tool.touched)
  1267.     {
  1268.       DRXG_tool_init(tool);
  1269.     }
  1270.  
  1271.   newwindow = (struct NewWindow *) (*functions->DupeNewWindow)(&DRXGNewWindowStructure1);
  1272.   if (!newwindow)
  1273.     {
  1274.       return;
  1275.     }
  1276.   newwindow->Title = 0;
  1277.   newwindow->Flags |= BORDERLESS;
  1278.   newwindow->Flags &= ~0xF;
  1279.   newwindow->BlockPen = 0;
  1280.   newwindow->DetailPen = 0;
  1281.  
  1282.   window = (struct Window *) (*functions->FlashyOpenWindow)(newwindow);
  1283.   if (!window)
  1284.     {
  1285.       return;
  1286.     }
  1287.  
  1288.  
  1289.   tool->tool.window = window;
  1290.   (*functions->EmbossWindowOn)(window, WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,  DRXG_NAME, (short)-1, (short)-1, 0, 0);
  1291.  
  1292.   (*functions->EmbossedPropOn)(window, KIT_GADGET, (void *)display_routine, 11, 0);
  1293.   (*functions->EmbossedPropOn)(window, INSTRUMENT_GADGET, (void *)display_routine, 79, 0);
  1294.   (*functions->EmbossedPropOn)(window, PITCHCOURSE_GADGET, (void *)display_routine, 128, 0);
  1295.  
  1296. for (i = PITCHCOURSE_GADGET; i <= VARFX_GADGET; i++)
  1297.     {
  1298.     (*functions->EmbossedPropOn)(window, i, (void *)display_routine, 128, 0);
  1299.     }
  1300.  
  1301.   (*functions->EmbossedPropOn)(window, KEYASSIGN_GADGET, (void *)display_routine, 2, 0);
  1302.   (*functions->EmbossedPropOn)(window, RCVNOTEOFF_GADGET, (void *)display_routine, 2, 0);
  1303.   (*functions->EmbossedPropOn)(window, RCVNOTEON_GADGET, (void *)display_routine, 2, 0);
  1304.  
  1305.  
  1306. for (i = FICUTOFFREQ_GADGET; i <= DECAYB_GADGET; i++)
  1307.     {
  1308.     (*functions->EmbossedPropOn)(window, i, (void *)display_routine, 128, 0);
  1309.     }
  1310.  
  1311.   (*functions->EmbossedPropOn)(window, VXON_GADGET, (void *)display_routine, 2, 0);
  1312.   (*functions->EmbossedPropOn)(window, DRUMSET_GADGET, (void *)display_routine, 2, 0);
  1313.  
  1314.  
  1315.   (*functions->EmbossOn)(window,  WRITE_GADGET,  1);
  1316.   (*functions->EmbossOn)(window,  DEFAULT_GADGET,  1);
  1317.  
  1318.   (*functions->ModifyEmbossedProp)(window,  KIT_GADGET,  tool->kit,  0,  0,  0,  0,  0);
  1319.   (*functions->ModifyEmbossedProp)(window,  INSTRUMENT_GADGET,  tool->instrument,  0,  0,  0,  0,  0);
  1320.   (*functions->ModifyEmbossedProp)(window,  PITCHCOURSE_GADGET,  tool->pitchcourse,  0,  0,  0,  0,  0);
  1321.   (*functions->ModifyEmbossedProp)(window,  PITCHFINE_GADGET,  tool->pitchfine,  0,  0,  0,  0,  0);
  1322.   (*functions->ModifyEmbossedProp)(window,  LEVEL_GADGET,  tool->level,  0,  0,  0,  0,  0);
  1323.   (*functions->ModifyEmbossedProp)(window,  ALTERNATE_GADGET,  tool->alternate,  0,  0,  0,  0,  0);
  1324.   (*functions->ModifyEmbossedProp)(window,  PAN_GADGET,  tool->pan,  0,  0,  0,  0,  0);
  1325.   (*functions->ModifyEmbossedProp)(window,  REVERB_GADGET,  tool->reverb,  0,  0,  0,  0,  0);
  1326.   (*functions->ModifyEmbossedProp)(window,  CHORUS_GADGET,  tool->chorus,  0,  0,  0,  0,  0);
  1327.   (*functions->ModifyEmbossedProp)(window,  VARFX_GADGET,  tool->varfx,  0,  0,  0,  0,  0);
  1328.   (*functions->ModifyEmbossedProp)(window,  KEYASSIGN_GADGET,  tool->keyassign,  0,  0,  0,  0,  0);
  1329.   (*functions->ModifyEmbossedProp)(window,  RCVNOTEOFF_GADGET,  tool->rcvnoteoff,  0,  0,  0,  0,  0);
  1330.   (*functions->ModifyEmbossedProp)(window,  RCVNOTEON_GADGET,  tool->rcvnoteon,  0,  0,  0,  0,  0);
  1331.   (*functions->ModifyEmbossedProp)(window,  FICUTOFFREQ_GADGET,  tool->ficutoffreq,  0,  0,  0,  0,  0);
  1332.   (*functions->ModifyEmbossedProp)(window,  FICUTOFFRESON_GADGET,  tool->ficutoffreson,  0,  0,  0,  0,  0);
  1333.   (*functions->ModifyEmbossedProp)(window,  ATTACK_GADGET,  tool->attack,  0,  0,  0,  0,  0);
  1334.   (*functions->ModifyEmbossedProp)(window,  DECAYA_GADGET,  tool->decaya,  0,  0,  0,  0,  0);
  1335.   (*functions->ModifyEmbossedProp)(window,  DECAYB_GADGET,  tool->decayb,  0,  0,  0,  0,  0);
  1336.   (*functions->ModifyEmbossedProp)(window,  VXON_GADGET,  tool->vxon,  0,  0,  0,  0,  0);
  1337.   (*functions->ModifyEmbossedProp)(window,  DRUMSET_GADGET,  tool->drumset,  0,  0,  0,  0,  0);
  1338.  
  1339.  for (i= KIT_GADGET; i<=DRUMSET_GADGET ; i++)
  1340.      {
  1341.         (*functions->DrawEmbossedProp)(window,  i);
  1342.      }
  1343.  
  1344.   trans_hx(tool,  functions->timenow,  "F043104c02015a01f7", 0);
  1345.   initvx(tool, functions->timenow);
  1346.   send_note(tool,  functions->timenow,  13);
  1347.   for (;;)
  1348.     {
  1349.       message = (struct IntuiMessage *) (*functions->GetIntuiMessage)(window);
  1350.       class = message->Class;
  1351.       code = message->Code;
  1352.       gadget = (struct Gadget *) message->IAddress;
  1353.       class = (*functions->SystemGadgets)(window, class, gadget, code);
  1354.  
  1355.       ReplyMsg((struct Message *)message);
  1356.  
  1357.  
  1358.       if (class == CLOSEWINDOW)
  1359.         {
  1360.           break;
  1361.         }
  1362.       else if (class == GADGETDOWN)
  1363.         {
  1364.           const short id = gadget->GadgetID;
  1365.           a = ((tool->valstorage[1])-13)*20;
  1366.  
  1367.           switch (id)
  1368.             {
  1369.             case KIT_GADGET:
  1370.               tool->kit = (UBYTE) (*functions->DragEmbossedProp)(window,  KIT_GADGET);
  1371.               if (tool->kit <= 8)
  1372.                   {
  1373.                   tool->writesw[0] = 1;
  1374.                   tool->msba = 127;
  1375.                   }
  1376.               if (tool->kit == 9)
  1377.                   {
  1378.                   tool->kit = 0;
  1379.                   tool->msba = 126;
  1380.                   }
  1381.               if (tool->kit == 10)
  1382.                   {
  1383.                   tool->kit = 1;
  1384.                   tool->msba = 126;
  1385.                   }
  1386.                   msba_event = (struct Event *)(*functions->allocevent)();
  1387.                   if (msba_event)
  1388.                   {
  1389.                    msbb_event = (struct Event *)(*functions->allocevent)();
  1390.                    if (msbb_event)
  1391.                    {
  1392.                     pc_event = (struct Event *)(*functions->allocevent)();
  1393.                     if (pc_event)
  1394.                     {
  1395.                                msba_event->type     =
  1396.                                msbb_event->type     =
  1397.                                pc_event->type       =  EVENT_VOICE;
  1398.  
  1399.                                msba_event->status   =
  1400.                                msbb_event->status   = MIDI_CCHANGE;
  1401.  
  1402.                                msba_event->byte1 = 0x00;
  1403.                                msba_event->byte2 = tool->msba;
  1404.  
  1405.                                msbb_event->byte1 = 0x20;
  1406.                                msbb_event->byte2 = 0x00;
  1407.  
  1408.                                pc_event->status = MIDI_PCHANGE;
  1409.                                pc_event->byte1  = kittypbyte[tool->kit];
  1410.  
  1411.                                time = functions->timenow;
  1412.  
  1413.                                msba_event->time       = time;
  1414.                                msbb_event->time       = time + 1;
  1415.                                pc_event->time         = time + 2;
  1416.  
  1417.                                msba_event->tool       =
  1418.                                msbb_event->tool       =
  1419.                                pc_event->tool         = tool->tool.next;
  1420.  
  1421.                                msba_event->next       = msbb_event;
  1422.                                msbb_event->next       = pc_event;
  1423.                                pc_event->next         = NULL;
  1424.  
  1425.                                (*functions->qevent)(msba_event);
  1426.                                (*functions->qevent)(msbb_event);
  1427.                                (*functions->qevent)(pc_event);
  1428.                     }
  1429.                     else
  1430.                     {
  1431.                     (*functions->freeevent)(msba_event);
  1432.                     (*functions->freeevent)(msbb_event);
  1433.                     }
  1434.                    }
  1435.                    else
  1436.                    {
  1437.                    (*functions->freeevent)(msba_event);
  1438.                    }
  1439.                   }
  1440.  
  1441.               defaultslider(tool, window);
  1442.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1443.               break;
  1444.             case INSTRUMENT_GADGET:
  1445.               tool->instrument = (UBYTE)(*functions->DragEmbossedProp)(window,  INSTRUMENT_GADGET);
  1446.               tool->valstorage[1] = (tool->instrument)+13;
  1447.               initslider(tool, window);
  1448.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1449.               break;
  1450.             case PITCHCOURSE_GADGET:
  1451.               tool->pitchcourse = (UBYTE) (*functions->DragEmbossedProp)(window, PITCHCOURSE_GADGET);
  1452.               tool->valstorage[2+a] = tool->pitchcourse;
  1453.               tool->writesw[2+a] = 1;
  1454.               sprintf(storage2, "F043104C3%1lx%02lx00%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->pitchcourse);
  1455.               tool->pitchcoursesysex = storage2;
  1456.               time = functions->timenow;
  1457.               trans_hx(tool,  time,  tool->pitchcoursesysex, 0);
  1458.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1459.               break;
  1460.             case PITCHFINE_GADGET:
  1461.               tool->pitchfine = (UBYTE) (*functions->DragEmbossedProp)(window, PITCHFINE_GADGET);
  1462.               tool->valstorage[3+a] = tool->pitchfine;
  1463.               tool->writesw[3+a] = 1;
  1464.               sprintf(storage3, "F043104C3%1lx%02lx01%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->pitchfine);
  1465.               tool->pitchfinesysex = storage3;
  1466.               time = functions->timenow;
  1467.               trans_hx(tool,  time,  tool->pitchfinesysex, 0);
  1468.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1469.               break;
  1470.             case LEVEL_GADGET:
  1471.               tool->level = (UBYTE) (*functions->DragEmbossedProp)(window, LEVEL_GADGET);
  1472.               tool->valstorage[4+a] = tool->level;
  1473.               tool->writesw[4+a] = 1;
  1474.               sprintf(storage4, "F043104C3%1lx%02lx02%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->level);
  1475.               tool->levelsysex = storage4;
  1476.               time = functions->timenow;
  1477.               trans_hx(tool,  time,  tool->levelsysex, 0);
  1478.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1479.               break;
  1480.             case ALTERNATE_GADGET:
  1481.               tool->alternate = (UBYTE) (*functions->DragEmbossedProp)(window, ALTERNATE_GADGET);
  1482.               tool->valstorage[6+a] = tool->alternate;
  1483.               tool->writesw[5+a] = 1;
  1484.               sprintf(storage5, "F043104C3%1lx%02lx03%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->alternate);
  1485.               tool->alternatesysex = storage5;
  1486.               time = functions->timenow;
  1487.               trans_hx(tool,  time,  tool->alternatesysex, 0);
  1488.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1489.               break;
  1490.             case PAN_GADGET:
  1491.               tool->pan = (UBYTE) (*functions->DragEmbossedProp)(window,  PAN_GADGET);
  1492.               tool->valstorage[6+a] = tool->pan;
  1493.               tool->writesw[6+a] = 1;
  1494.               sprintf(storage6, "F043104C3%1lx%02lx04%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->pan);
  1495.               tool->pansysex = storage6;
  1496.               time = functions->timenow;
  1497.               trans_hx(tool,  time,  tool->pansysex, 0);
  1498.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1499.               break;
  1500.             case REVERB_GADGET:
  1501.               tool->reverb = (UBYTE) (*functions->DragEmbossedProp)(window,  REVERB_GADGET);
  1502.               tool->valstorage[7+a] = tool->reverb;
  1503.               tool->writesw[7+a] = 1;
  1504.               sprintf(storage7, "F043104C3%1lx%02lx05%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->reverb);
  1505.               tool->reverbsysex = storage7;
  1506.               time = functions->timenow;
  1507.               trans_hx(tool,  time,  tool->reverbsysex, 0);
  1508.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1509.               break;
  1510.             case CHORUS_GADGET:
  1511.               tool->chorus = (UBYTE) (*functions->DragEmbossedProp)(window,  CHORUS_GADGET);
  1512.               tool->valstorage[8+a] = tool->chorus;
  1513.               tool->writesw[8+a] = 1;
  1514.               sprintf(storage8, "F043104C3%1lx%02lx06%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->chorus);
  1515.               tool->chorussysex = storage8;
  1516.               time = functions->timenow;
  1517.               trans_hx(tool,  time,  tool->chorussysex, 0);
  1518.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1519.               break;
  1520.             case VARFX_GADGET:
  1521.               tool->varfx = (UBYTE) (*functions->DragEmbossedProp)(window,  VARFX_GADGET);
  1522.               tool->valstorage[9+a] = tool->varfx;
  1523.               tool->writesw[9+a] = 1;
  1524.               sprintf(storage9, "F043104C3%1lx%02lx07%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->varfx);
  1525.               tool->varfxsysex = storage9;
  1526.               time = functions->timenow;
  1527.               trans_hx(tool,  time,  tool->varfxsysex, 0);
  1528.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1529.               break;
  1530.             case KEYASSIGN_GADGET:
  1531.               tool->keyassign = (UBYTE) (*functions->DragEmbossedProp)(window,  KEYASSIGN_GADGET);
  1532.               tool->valstorage[10+a] = tool->keyassign;
  1533.               tool->writesw[10+a] = 1;
  1534.               sprintf(storage10, "F043104C3%1lx%02lx08%02lxF7",tool->valstorage[19],tool->valstorage[1], tool->keyassign);
  1535.               tool->keyassignsysex = storage10;
  1536.               time = functions->timenow;
  1537.               trans_hx(tool,  time,  tool->keyassignsysex, 0);
  1538.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1539.               break;
  1540.             case RCVNOTEOFF_GADGET:
  1541.               tool->rcvnoteoff = (UBYTE) (*functions->DragEmbossedProp)(window,  RCVNOTEOFF_GADGET);
  1542.               tool->valstorage[11+a] = tool->rcvnoteoff;
  1543.               tool->writesw[11+a] = 1;
  1544.               sprintf(storage11, "F043104C3%1lx%02lx09%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->rcvnoteoff);
  1545.               tool->rcvnoteoffsysex = storage11;
  1546.               time = functions->timenow;
  1547.               trans_hx(tool,  time,  tool->rcvnoteoffsysex, 0);
  1548.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1549.               break;
  1550.             case RCVNOTEON_GADGET:
  1551.               tool->rcvnoteon = (UBYTE) (*functions->DragEmbossedProp)(window,  RCVNOTEON_GADGET);
  1552.               tool->valstorage[12+a] = tool->rcvnoteon;
  1553.               tool->writesw[12+a] = 1;
  1554.               sprintf(storage12, "F043104C3%1lx%02lx0A%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->rcvnoteon);
  1555.               tool->rcvnoteonsysex = storage12;
  1556.               time = functions->timenow;
  1557.               trans_hx(tool,  time,  tool->rcvnoteonsysex, 0);
  1558.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1559.               break;
  1560.             case FICUTOFFREQ_GADGET:
  1561.               tool->ficutoffreq = (UBYTE) (*functions->DragEmbossedProp)(window,  FICUTOFFREQ_GADGET);
  1562.               tool->valstorage[13+a] = tool->ficutoffreq;
  1563.               tool->writesw[13+a] = 1;
  1564.               sprintf(storage13, "F043104C3%1lx%02lx0B%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->ficutoffreq);
  1565.               tool->ficutoffreqsysex = storage13;
  1566.               time = functions->timenow;
  1567.               trans_hx(tool,  time,  tool->ficutoffreqsysex, 0);
  1568.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1569.               break;
  1570.             case FICUTOFFRESON_GADGET:
  1571.               tool->ficutoffreson = (UBYTE) (*functions->DragEmbossedProp)(window,  FICUTOFFRESON_GADGET);
  1572.               tool->valstorage[14+a] = tool->ficutoffreson;
  1573.               tool->writesw[14+a] = 1;
  1574.               sprintf(storage14, "F043104C3%1lx%02lx0C%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->ficutoffreson);
  1575.               tool->ficutoffresonsysex = storage14;
  1576.               time = functions->timenow;
  1577.               trans_hx(tool,  time,  tool->ficutoffresonsysex, 0);
  1578.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1579.               break;
  1580.             case ATTACK_GADGET:
  1581.               tool->attack = (UBYTE) (*functions->DragEmbossedProp)(window,  ATTACK_GADGET);
  1582.               tool->valstorage[15+a] = tool->attack;
  1583.               tool->writesw[15+a] = 1;
  1584.               sprintf(storage15, "F043104C3%1lx%02lx0D%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->attack);
  1585.               tool->attacksysex = storage15;
  1586.               time = functions->timenow;
  1587.               trans_hx(tool,  time,  tool->attacksysex, 0);
  1588.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1589.               break;
  1590.             case DECAYA_GADGET:
  1591.               tool->decaya = (UBYTE) (*functions->DragEmbossedProp)(window,  DECAYA_GADGET);
  1592.               tool->valstorage[16+a] = tool->decaya;
  1593.               tool->writesw[16+a] = 1;
  1594.               sprintf(storage16, "F043104C3%1lx%02lx0E%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->decaya);
  1595.               tool->decayasysex = storage16;
  1596.               time = functions->timenow;
  1597.               trans_hx(tool,  time,  tool->decayasysex, 0);
  1598.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1599.               break;
  1600.             case DECAYB_GADGET:
  1601.               tool->decayb = (UBYTE) (*functions->DragEmbossedProp)(window,  DECAYB_GADGET);
  1602.               tool->valstorage[17+a] = tool->decayb;
  1603.               tool->writesw[17+a] = 1;
  1604.               sprintf(storage17, "F043104C3%1lx%02lx0F%02lxF7",tool->valstorage[19],tool->valstorage[1],tool->decayb);
  1605.               tool->decaybsysex = storage17;
  1606.               time = functions->timenow;
  1607.               trans_hx(tool,  time,  tool->decaybsysex, 0);
  1608.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1609.               break;
  1610.             case VXON_GADGET:
  1611.               tool->vxon = (UBYTE) (*functions->DragEmbossedProp)(window,  VXON_GADGET);
  1612.               tool->valstorage[18] = tool->vxon;
  1613.               tool->writesw[18] = 1;
  1614.               sprintf(storage18, "F043104C02015A%02lxF7",tool->vxon);
  1615.               tool->vxonsysex = storage18;
  1616.               time = functions->timenow;
  1617.               trans_hx(tool,  time,  tool->vxonsysex, 0);
  1618.               send_note(tool,  functions->timenow+30,  tool->valstorage[1]);
  1619.               break;
  1620.             case DRUMSET_GADGET:
  1621.               tool->drumset = (UBYTE) (*functions->DragEmbossedProp)(window,  DRUMSET_GADGET);
  1622.               tool->valstorage[19] = tool->drumset;
  1623.               tool->writesw[19] = 1;
  1624.               defaultslider(tool, window);
  1625.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1626.               break;
  1627.            case DEFAULT_GADGET:
  1628.               defaultslider(tool, window);
  1629.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1630.               break;
  1631.            case WRITE_GADGET:
  1632.               if ((*functions->areyousure)("write to track ? Play-pointer on right place ?"))
  1633.                   {
  1634.                   if (!functions->running)
  1635.                     {
  1636.                     time = functions->starttime;
  1637.                     if (time ==  0) time = 6;
  1638.  
  1639.                     msba_event = (struct Event *)(*functions->allocevent)();
  1640.                     if (msba_event)
  1641.                     {
  1642.                      msbb_event = (struct Event *)(*functions->allocevent)();
  1643.                      if (msbb_event)
  1644.                      {
  1645.                       pc_event = (struct Event *)(*functions->allocevent)();
  1646.                       if (pc_event)
  1647.                       {
  1648.                                  msba_event->type     =
  1649.                                  msbb_event->type     =
  1650.                                  pc_event->type       =  EVENT_VOICE;
  1651.  
  1652.                                  msba_event->status   =
  1653.                                  msbb_event->status   = MIDI_CCHANGE;
  1654.  
  1655.                                  msba_event->byte1 = 0x00;
  1656.                                  msba_event->byte2 = tool->msba;
  1657.  
  1658.                                  msbb_event->byte1 = 0x20;
  1659.                                  msbb_event->byte2 = 0x00;
  1660.  
  1661.                                  pc_event->status = MIDI_PCHANGE;
  1662.                                  pc_event->byte1  = kittypbyte[tool->kit];
  1663.  
  1664.                                  msba_event->time       = time;
  1665.                                  msbb_event->time       = time + 1;
  1666.                                  pc_event->time         = time + 2;
  1667.  
  1668.                                  msba_event->tool    =
  1669.                                  msbb_event->tool       =
  1670.                                  pc_event->tool         = tool->tool.next;
  1671.  
  1672.                                  msba_event->next       = msbb_event;
  1673.                                  msbb_event->next       = pc_event;
  1674.                                  pc_event->next         = NULL;
  1675.  
  1676.                                  if (lock_clip(&(tool->tool.track->clip)))
  1677.                                    {
  1678.                                      pc_event->next = tool->tool.track->clip.events.first;
  1679.                                      tool->tool.track->clip.events.first =
  1680.                                      (struct Event *)(*functions->sorteventlist)(msba_event);
  1681.                                      unlock_clip(&(tool->tool.track->clip));
  1682.                                    }
  1683.                                  else
  1684.                                    {
  1685.                                      (*functions->freelist)(msba_event);
  1686.                                    }
  1687.                       }
  1688.                       else
  1689.                       {
  1690.                       (*functions->freeevent)(msba_event);
  1691.                       (*functions->freeevent)(msbb_event);
  1692.                       }
  1693.                      }
  1694.                      else
  1695.                      {
  1696.                      (*functions->freeevent)(msba_event);
  1697.                      }
  1698.                     }
  1699.                     for (b=0; b<=79; b++)
  1700.                       {
  1701.                       if (tool->writesw[2+(b*20)] == 1)
  1702.                           {
  1703.                           sprintf(storage1, "F043104C3%1lx%02lx00%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+2]);
  1704.                           tool->pitchcoursesysex = storage1;
  1705.                           trans_hx(tool, time, tool->pitchcoursesysex, 1);
  1706.                           }
  1707.                       if (tool->writesw[3+(b*20)] == 1)
  1708.                           {
  1709.                           sprintf(storage2, "F043104C3%1lx%02lx01%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+3]);
  1710.                           tool->pitchfinesysex = storage2;
  1711.                           trans_hx(tool, time+1, tool->pitchfinesysex, 1);
  1712.                           }
  1713.                       if (tool->writesw[4+(b*20)] == 1)
  1714.                           {
  1715.                           sprintf(storage3, "F043104C3%1lx%02lx02%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+4]);
  1716.                           tool->levelsysex = storage3;
  1717.                           trans_hx(tool, time+2, tool->levelsysex, 1);
  1718.                           }
  1719.                       if (tool->writesw[5+(b*20)] == 1)
  1720.                           {
  1721.                           sprintf(storage4, "F043104C3%1lx%02lx03%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+5]);
  1722.                           tool->alternatesysex = storage4;
  1723.                           trans_hx(tool, time+3, tool->alternatesysex, 1);
  1724.                           }
  1725.                       if (tool->writesw[6+(b*20)] == 1)
  1726.                           {
  1727.                           sprintf(storage5, "F043104C3%1lx%02lx04%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+6]);
  1728.                           tool->pansysex = storage5;
  1729.                           trans_hx(tool, time+4, tool->pansysex, 1);
  1730.                           }
  1731.                       if (tool->writesw[7+(b*20)] == 1)
  1732.                           {
  1733.                           sprintf(storage6, "F043104C3%1lx%02lx05%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+7]);
  1734.                           tool->reverbsysex = storage6;
  1735.                           trans_hx(tool, time+5, tool->reverbsysex, 1);
  1736.                           }
  1737.                       if (tool->writesw[8+(b*20)] == 1)
  1738.                           {
  1739.                           sprintf(storage7, "F043104C3%1lx%02lx06%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+8]);
  1740.                           tool->chorussysex = storage7;
  1741.                           trans_hx(tool, time+6, tool->chorussysex, 1);
  1742.                           }
  1743.                       if (tool->writesw[9+(b*20)] == 1)
  1744.                           {
  1745.                           sprintf(storage8, "F043104C3%1lx%02lx07%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+9]);
  1746.                           tool->varfxsysex = storage8;
  1747.                           trans_hx(tool, time+7, tool->varfxsysex, 1);
  1748.                           }
  1749.                       if (tool->writesw[10+(b*20)] == 1)
  1750.                           {
  1751.                           sprintf(storage9, "F043104C3%1lx%02lx08%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+10]);
  1752.                           tool->keyassignsysex = storage9;
  1753.                           trans_hx(tool, time+8, tool->keyassignsysex, 1);
  1754.                           }
  1755.                       if (tool->writesw[11+(b*20)] == 1)
  1756.                           {
  1757.                           sprintf(storage10, "F043104C3%1lx%02lx09%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+11]);
  1758.                           tool->rcvnoteoffsysex = storage10;
  1759.                           trans_hx(tool, time+9, tool->rcvnoteoffsysex, 1);
  1760.                           }
  1761.                       if (tool->writesw[12+(b*20)] == 1)
  1762.                           {
  1763.                           sprintf(storage11, "F043104C3%1lx%02lx0A%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+12]);
  1764.                           tool->rcvnoteonsysex = storage11;
  1765.                           trans_hx(tool, time+10, tool->rcvnoteonsysex, 1);
  1766.                           }
  1767.                       if (tool->writesw[13+(b*20)] == 1)
  1768.                           {
  1769.                           sprintf(storage12, "F043104C3%1lx%02lx0D%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+13]);
  1770.                           tool->ficutoffreqsysex = storage12;
  1771.                           trans_hx(tool, time+11, tool->ficutoffreqsysex, 1);
  1772.                           }
  1773.                       if (tool->writesw[14+(b*20)] == 1)
  1774.                           {
  1775.                           sprintf(storage13, "F043104C3%1lx%02lx6E%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+14]);
  1776.                           tool->ficutoffresonsysex = storage13;
  1777.                           trans_hx(tool, time+12, tool->ficutoffresonsysex, 1);
  1778.                           }
  1779.                       if (tool->writesw[15+(b*20)] == 1)
  1780.                           {
  1781.                           sprintf(storage14, "F043104C3%1lx%02lx0E%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+15]);
  1782.                           tool->attacksysex = storage14;
  1783.                           trans_hx(tool, time+13, tool->attacksysex, 1);
  1784.                           }
  1785.                       if (tool->writesw[16+(b*20)] == 1)
  1786.                           {
  1787.                           sprintf(storage15, "F043104C3%1lx%02lx10%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+16]);
  1788.                           tool->decayasysex = storage15;
  1789.                           trans_hx(tool, time+14, tool->decayasysex, 1);
  1790.                           }
  1791.                       if (tool->writesw[17+(b*20)] == 1)
  1792.                           {
  1793.                           sprintf(storage16, "F043104C3%1lx%02lx0F%02lxF7",tool->drumset,b,tool->valstorage[(b*20)+17]);
  1794.                           tool->decaybsysex = storage16;
  1795.                           trans_hx(tool, time+15, tool->decaybsysex, 1);
  1796.                           }
  1797.                       if (tool->writesw[18+(b*20)] == 1)
  1798.                           {
  1799.                           sprintf(storage17, "F043104C3%1lx%02lx11%02lxF7",tool->drumset,b,tool->valstorage[18]);
  1800.                           tool->vxonsysex = storage17;
  1801.                           trans_hx(tool, time+16, tool->vxonsysex, 1);
  1802.                           }
  1803.                       time=time+20;
  1804.                       }
  1805.                     }
  1806.                   }
  1807.               send_note(tool,  functions->timenow,  tool->valstorage[1]);
  1808.               break;
  1809.             default:
  1810.               break;
  1811.             }
  1812.         }
  1813.       else if (class == GADGETUP)
  1814.         {
  1815.           /* Nothing. */
  1816.         }
  1817.     }
  1818.   tool->tool.window = 0;
  1819.   tool->tool.left = window->LeftEdge;
  1820.   tool->tool.top = window->TopEdge;
  1821.   tool->tool.width = window->Width;
  1822.   tool->tool.height = window->Height;
  1823.   tool->tool.touched = TOUCH_INIT | TOUCH_EDIT;
  1824.  
  1825.   for (i = KIT_GADGET;
  1826.        i <= DRUMSET_GADGET;
  1827.        i ++)
  1828.     {
  1829.       (*functions->EmbossedPropOff)(window, i);
  1830.     }
  1831.  
  1832.   (*functions->EmbossOff)(window,  WRITE_GADGET);
  1833.   (*functions->EmbossOff)(window,  DEFAULT_GADGET);
  1834.  
  1835.   (*functions->EmbossWindowOff)(window);
  1836.   (*functions->FlashyCloseWindow)(window);
  1837.   (*functions->DeleteNewWindow)(newwindow);
  1838. }
  1839.  
  1840. //to leave the tool correct
  1841.  
  1842. void __saveds removetool()
  1843. {
  1844. FreeVec(matrix);
  1845. FreeVec(DRXG);
  1846. }
  1847.  
  1848. //start of the tool
  1849.  
  1850. struct ToolMaster * inittoolmaster()
  1851. {
  1852.   int i = 0,  pkit = 0;
  1853.  
  1854.   if (!(DRXG=(UWORD *)AllocVec(sizeof (DRXGdata), MEMF_CHIP|MEMF_CLEAR))) return(NULL);
  1855.   CopyMem(&DRXGdata, DRXG,  sizeof (DRXGdata));
  1856.  
  1857.   if(!(matrix = (STRPTR *)AllocVec(MAX_KITS*MAX_INSTRUMENTS*sizeof(STRPTR), MEMF_ANY|MEMF_CLEAR)))
  1858.   return(NULL);
  1859.  
  1860.    while (dr[i].kit != BE)
  1861.    {
  1862.  
  1863.        pkit = dr[i].kit;
  1864.        matrix[pkit * MAX_INSTRUMENTS + dr[i].instrument] = (STRPTR)dr[i].name;
  1865.        i++;
  1866.    }
  1867.  
  1868.  
  1869.   DRXG_image.ImageData = DRXG;
  1870.   memset((char *)&master, 0, sizeof(struct ToolMaster));
  1871.   master.toolid = DRXG_ID;
  1872.   master.image = &DRXG_image;
  1873.   strcpy(master.name,  DRXG_NAME);
  1874.   master.edittool = edittoolcode;
  1875.   master.processevent = processeventcode;
  1876.   master.tooltype = DRXG_TYPE;
  1877.   master.toolsize = sizeof(struct DRXGTool);
  1878.   master.removetool = removetool;
  1879.   return(&master);
  1880. }
  1881.  
  1882.  
  1883.